using System;
using System.Collections.Generic;
using System.Text;

namespace GetTogether.Studio.Logging
{
    public class ProjectParameter : GetTogether.ObjectBase.SerializationBase<ProjectParameter>
    {
        public ProjectParameter()
        {
            _Url = "http://127.0.0.1/Logs/";
            _ProjectName = "GetTogether";
            _Category = "Unknown";
        }

        private string _Category;

        public string Category
        {
            get
            {
                if (string.IsNullOrEmpty(_Category) || this._Category == "Unknown")
                {
                    if (!string.IsNullOrEmpty(_Url) && this.ProjectName != "GetTogether")
                    {
                        string[] addressInfo = _Url.Split(new string[] { "//" }, StringSplitOptions.None);
                        if (addressInfo.Length > 0)
                        {
                            return addressInfo[(addressInfo.Length >= 2 ? 1 : 0)].Split('/')[0];
                        }
                        else
                        {
                            return "Unknown";
                        }
                    }
                    else
                        return "Unknown";
                }
                return _Category;
            }
            set { _Category = value; }
        }

        private string _ProjectName;

        public string ProjectName
        {
            get { return _ProjectName; }
            set { _ProjectName = value; }
        }

        private string _Url;

        public string Url
        {
            get { return _Url; }
            set { _Url = value; }
        }

        #region Functions

        public static string GetSettingsPathPublic()
        {
            return GetTogether.Studio.ProjectParameter.GetSettingsPathPublic(GetTogether.Studio.ProjectParameter.ProjectCategory.Logging);
        }

        public static string GetSettingsPath(string username)
        {
            return GetTogether.Studio.ProjectParameter.GetSettingsPath(GetTogether.Studio.ProjectParameter.ProjectCategory.Logging, username);
        }

        public static ProjectParameter GetSettingsByProjectName(string username, string projName, string shareUsername)
        {
            return GetTogether.Studio.ProjectParameter.GetSettingsByProjectName<ProjectParameter>(GetTogether.Studio.ProjectParameter.ProjectCategory.Logging, username, projName, shareUsername);
        }

        #endregion
    }
}
